<?

	////
	///
	//	Query Log In & Out

		function JC_LI( ) { // Log In

			$RS = JC_query( "SELECT * FROM `account` WHERE `identifier` = '" . $_REQUEST[ "JC_identifier" ] . "' AND `password` = '" . $_REQUEST[ "JC_password" ] . "'" );

			if( $RS ) $record = $RS -> fetch_array( );

			$_SESSION[ "JC_account_key"			] = $record[ "key"			];
			$_SESSION[ "JC_account_identifier"	] = $record[ "identifier"	];
			$_SESSION[ "JC_account_authority"	] = $record[ "authority"	];
			$_SESSION[ "JC_account_name"		] = $record[ "name"			];

			JC_LR( );

		}

		function JC_LO( ) { // Log Out

			session_destroy( );

			JC_LR( "?" );

		}



	////
	///
	//	Database

		function JC_query( $query ) {

			global $JC_MySQL;

			// JC_82_log_query

			// echo $query;

			return $JC_MySQL -> query( $query );

		}

		function JC_scheme( ) {

			global $JC_database_database;

			$RS_table = JC_query( "SHOW TABLE STATUS FROM `" . $JC_database_database . "`" );

			while( $record_table = $RS_table -> fetch_array( ) ) {

				$RS_field = JC_query( "SHOW FULL FIELDS FROM `" . $record_table[ "Name" ] . "`" );

				$_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ "comment" ] = $record_table[ "Comment" ];

				while( $record_field = $RS_field -> fetch_array( ) ) {

					$_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ] = JC_TA( $record_field[ "Comment" ] );
					$_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ][ "type" ] = $record_field[ "Type" ];
					$_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ][ "null" ] = ( $record_field[ "Null" ] == "YES" ? true : false );

					if( ! JC_authority( $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ "key" ][ "AS" ] ) ) {

						unset( $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ] );

						break;

					}

					if( ! JC_authority( $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ][ "AS" ] ) ) {

						unset( $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ] );

						continue;

					}

					if( $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] ][ 'FKF' ] ) $_SESSION[ "JC_scheme" ][ $record_table[ "Name" ] ][ $record_field[ "Field" ] . " FKF" ] = null;

					$_SESSION[ "JC_filter_omit_" . $record_table[ "Name" ] . ".note" ] = "on";
					$_SESSION[ "JC_filter_omit_" . $record_table[ "Name" ] . ".log" ] = "on";
					$_SESSION[ "JC_filter_omit_" . $record_table[ "Name" ] . ".insert" ] = "on";
					$_SESSION[ "JC_filter_omit_" . $record_table[ "Name" ] . ".update" ] = "on";
					$_SESSION[ "JC_filter_omit_" . $record_table[ "Name" ] . ".delete" ] = "on";

				}

			}

			$temporary = array( );

			foreach( $_SESSION[ "JC_scheme" ] as $key => $value ) array_push( $temporary, intval( $_SESSION[ "JC_scheme" ][ $key ][ "key" ][ "priority" ] ) );

			array_multisort( $temporary, $_SESSION[ "JC_scheme" ] );

			$_SESSION[ "JC_scheme" ] = array_reverse( $_SESSION[ "JC_scheme" ] );

		}

		function JC_filter( $initialization = false ) {

			if( $initialization ) unset( $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] );

			$RS = JC_query( "SELECT MAX( `key` ) AS `key` FROM `" . $_REQUEST[ "JC_table" ] . "`" );

			if( $RS ) $record = $RS -> fetch_array( );

			if( ! intval( $_SESSION[ "JC_filter_KE_" . $_REQUEST[ "JC_table" ] ] ) || $initialization ) $_SESSION[ "JC_filter_KE_" . $_REQUEST[ "JC_table" ] ] = ( $record[ "key" ] ? $record[ "key" ]	: 0 ); // Key End
			if( ! intval( $_SESSION[ "JC_filter_KS_" . $_REQUEST[ "JC_table" ] ] ) || $initialization ) $_SESSION[ "JC_filter_KS_" . $_REQUEST[ "JC_table" ] ] = ( $record[ "key" ] ? 1					: 0 ); // Key Start

			if( ! $_SESSION[ "JC_filter_OF_" . $_REQUEST[ "JC_table" ] ] || $initialization ) $_SESSION[ "JC_filter_OF_" . $_REQUEST[ "JC_table" ] ] = "key"	; // Order Field
			if( ! $_SESSION[ "JC_filter_OT_" . $_REQUEST[ "JC_table" ] ] || $initialization ) $_SESSION[ "JC_filter_OT_" . $_REQUEST[ "JC_table" ] ] = "DESC"	; // Order Type

			if( ! intval( $_SESSION[ "JC_filter_page_"	. $_REQUEST[ "JC_table" ] ] ) || $initialization	) $_SESSION[ "JC_filter_page_"	. $_REQUEST[ "JC_table" ] ] = "1"	;
			if( ! intval( $_SESSION[ "JC_filter_limit_"	. $_REQUEST[ "JC_table" ] ] )					) $_SESSION[ "JC_filter_limit_"	. $_REQUEST[ "JC_table" ] ] = "10"	;

		}

		function JC_page( ) {

			$query =	"SELECT COUNT( `key` ) AS 'count'";
			$query .=	" FROM `" . $_REQUEST[ "JC_table" ] . "`";
			$query .=	" WHERE TRUE";

			////
			///
			//	Search

				if( $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] ) {

					$query .= " AND (";

					foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

						if( $key == "comment"															) continue;
						if( ! $_SESSION[ "JC_filter_SF_" . $_REQUEST[ "JC_table" ] . "." . $key ]	) continue;

						$temporary = true;

						if( ! strpos( $key, " FKF" ) ) {

							$query .= " `" . $key . "` LIKE '%" . $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] . "%' OR";

						} else {

							$RS = JC_query( "
								SELECT `key`
								FROM `"		. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKT" ] . "`
								WHERE `"	. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKF" ] . "`
								LIKE '%"	. $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] . "%'
							" );

							if( $RS ) while( $record = $RS -> fetch_array( ) ) $query .= " `" . str_replace( " FKF", "", $key ) . "` = '" . $record[ "key" ] . "' OR";

						}

					}

					if( $temporary ) {

						$query = substr( $query, 0, -3 );
						$query .= " )";

					} else {

						$query .= " TRUE )";

					}

				}

			////
			///
			//	Key

				$query .= " AND `key` >= '" . intval( $_SESSION[ "JC_filter_KS_" . $_REQUEST[ "JC_table" ] ] ) . "'";
				$query .= " AND `key` <= '" . intval( $_SESSION[ "JC_filter_KE_" . $_REQUEST[ "JC_table" ] ] ) . "'";

			////
			///
			//	Omit

				if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . ".delete" ] ) $query .= " AND `delete` IS NULL";

			$RS = JC_query( $query );

			if( $RS ) $record = $RS -> fetch_array( );

			return floor( ( $record[ "count" ] - 1 ) / intval( $_SESSION[ "JC_filter_limit_" . $_REQUEST[ "JC_table" ] ] ) ) + 1;

		}



	////
	///
	//	Query Select, Insert, Update & Delete

		function JC_select( ) {

			JC_filter( );

			$query = "SELECT";

			////
			///
			//	Field

				foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

					if( $key == "comment"															) continue;
					if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . "." . $key ]	) continue;

					if( ! strpos( $key, " FKF" ) ) {

						$query .= " `" . $key . "`,";

					} else {

						if( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "type" ] != "text" ) {

							$query .= " ( SELECT `"	. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKF" ] . "`";
							$query .= " FROM `"		. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKT" ] . "`";
							$query .= " WHERE `key` = `" . str_replace( " FKF", "", $key ) . "` )";
							$query .= " AS '" . str_replace( " FKF", "", $key ) . " FKF" . "',";

						} else {

							$query .= " `JC_FK_" . $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKT" ] . "." . $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKF" ] . "`( `" . str_replace( " FKF", "", $key ) . "` ) AS `" . $key . "`,";

						}

					}

				}

				$query = substr( $query, 0, -1 );

			////
			///
			//	Table

				$query .= " FROM `" . $_REQUEST[ "JC_table" ] . "`";

			////
			///
			//	Where

				$query .= " WHERE TRUE";

			////
			///
			//	Search

				if( $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] ) {

					$query .= " AND (";

					foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

						if( $key == "comment" ) continue;
						if( ! $_SESSION[ "JC_filter_SF_" . $_REQUEST[ "JC_table" ] . "." . $key ] ) continue;

						$temporary = true;

						if( ! strpos( $key, " FKF" ) ) {

							$query .= " `" . $key . "` LIKE '%" . $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] . "%' OR";

						} else {

							$RS = JC_query( "
								SELECT `key`
								FROM `"		. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKT" ] . "`
								WHERE `"	. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ str_replace( " FKF", "", $key ) ][ "FKF" ] . "`
								LIKE '%"	. $_SESSION[ "JC_filter_ST_" . $_REQUEST[ "JC_table" ] ] . "%'
							" );

							if( $RS ) while( $record = $RS -> fetch_array( ) ) $query .= " `" . str_replace( " FKF", "", $key ) . "` = '" . $record[ "key" ] . "' OR";

						}

					}

					if( $temporary ) {

						$query = substr( $query, 0, -3 );
						$query .= " )";

					} else {

						$query .= " TRUE )";

					}

				}

			////
			///
			//	Key

				$query .= " AND `key` >= '" . intval( $_SESSION[ "JC_filter_KS_" . $_REQUEST[ "JC_table" ] ] ) . "'";
				$query .= " AND `key` <= '" . intval( $_SESSION[ "JC_filter_KE_" . $_REQUEST[ "JC_table" ] ] ) . "'";

			////
			///
			//	Omit

				if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . ".delete" ] ) $query .= " AND `delete` IS NULL";

			////
			///
			//	Order

				$query .= " ORDER BY `" . $_SESSION[ "JC_filter_OF_" . $_REQUEST[ "JC_table" ] ] . "` " . $_SESSION[ "JC_filter_OT_" . $_REQUEST[ "JC_table" ] ] . "";

			////
			///
			//	Limit

				$query .= " LIMIT " . $_SESSION[ "JC_filter_limit_" . $_REQUEST[ "JC_table" ] ] . " OFFSET " . ( ( $_SESSION[ "JC_filter_page_" . $_REQUEST[ "JC_table" ] ] - 1 ) * $_SESSION[ "JC_filter_limit_" . $_REQUEST[ "JC_table" ] ] );

			return JC_query( $query );

		}

		function JC_insert( ) {

			foreach( $_REQUEST as $key => $value ) $_REQUEST[ $key ] = addslashes( $_REQUEST[ $key ] );

			for( $i = 0; $i < intval( $_SESSION[ "JC_insert_multiple_" . $_REQUEST[ "JC_table" ] ] ); $i ++ ) {

				if( $_REQUEST[ "JC_insert_form" ] != "every" && $_REQUEST[ "JC_insert_form" ] != $i ) continue;

				////
				///
				//	Validation

					$temporary = false;				

					foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) if( ! empty( $_REQUEST[ "JC_insert_" . $key . "_" . $i ] ) ) $temporary = true;

					if( ! $temporary ) continue;

				$query = "INSERT INTO " . $_REQUEST[ "JC_table" ] . " (";

				foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

					if( $key == "comment"						) continue;
					if( $key == "key"							) continue;
					if( $key == "update"						) continue;
					if( $key == "delete"						) continue;
					if( strpos( $key, " FKF" )					) continue;
					if( ! JC_authority( $value[ "AIUD" ] )	) continue;

					$query .= " `" . $key . "`,";

				}

				$query = substr( $query, 0, -1 );

				$query .= " ) VALUES (";

				foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

					if( $key == "comment"						) continue;
					if( $key == "key"							) continue;
					if( $key == "log"							) continue;
					if( $key == "insert"						) continue;
					if( $key == "update"						) continue;
					if( $key == "delete"						) continue;
					if( strpos( $key, " FKF" )					) continue;
					if( ! JC_authority( $value[ "AIUD" ] )	) continue;

					if( $_REQUEST[ "JC_table" ] == "file" && $key == "name" ) {

						$name = JC_FI( $i );

						if( $name ) $_REQUEST[ "JC_insert_" . $key . "_" . $i ] = $name;

					}

					if( ! is_array( $_REQUEST[ "JC_insert_" . $key . "_" . $i ] ) ) {

						$query .= " " . ( $_REQUEST[ "JC_insert_" . $key . "_" . $i ] ? "'" . $_REQUEST[ "JC_insert_" . $key . "_" . $i ] . "'" : ( $value[ "null" ] ? "NULL" : "''" ) ) . ",";

					} else {

						foreach( $_REQUEST[ "JC_insert_" . $key . "_" . $i ] as $key_text => $value_text ) ( ! $text ? $text = $value_text : $text .= "\r\n" . $value_text );

						$query .= " " . ( $text ? "'" . $text . "'" : ( $value[ "null" ] ? "NULL" : "''" ) ) . ",";

					}

				}

				$query .= " CONCAT( NOW( ), ' " . $_SESSION[ "JC_account_key" ] . "\r\n' ), NOW( ) )";

				JC_query( $query );

			}

			JC_filter( true );

			if( $_REQUEST[ "JC_insert_form" ] == "every" ) {

				JC_LR( );

			} else {

				echo "<b>Asynchronous</b> : " . $query;

				echo "<script>";

				foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

					if( $key == "comment"						) continue;
					if( $key == "key"							) continue;
					if( $key == "log"							) continue;
					if( $key == "insert"						) continue;
					if( $key == "update"						) continue;
					if( $key == "delete"						) continue;
					if( strpos( $key, " FKF" )					) continue;
					if( ! JC_authority( $value[ "AIUD" ] )	) continue;

					echo "parent.document.getElementById( 'JC_insert_" . $key . "_" . $_REQUEST[ "JC_insert_form" ] . "' ).value = '';";

				}

				echo "</script>";

			}

		}

		function JC_update( ) {

			foreach( $_REQUEST as $key => $value ) $_REQUEST[ $key ] = addslashes( $_REQUEST[ $key ] );

			$query = "UPDATE `" . $_REQUEST[ "JC_table" ] . "` SET";

			foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) {

				if( $key == "comment"															) continue;
				if( $key == "key"																) continue;
				if( $key == "log"																) continue;
				if( $key == "insert"															) continue;
				if( $key == "update"															) continue;
				if( $key == "delete"															) continue;
				if( strpos( $key, " FKF" )														) continue;
				if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . "." . $key ]	) continue;

				if( $_REQUEST[ "JC_table" ] == "file" && $key == "host" ) $name = JC_FU( ); // ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****

				if( ! is_array( $_REQUEST[ "JC_update_" . $key ] ) ) {

					$query .= " `" . $key . "` = " . ( $_REQUEST[ "JC_update_" . $key ] ? "'" . $_REQUEST[ "JC_update_" . $key ] . "' " : ( $value[ "null" ] ? "NULL" : "''" ) ) . ",";

				} else {

					foreach( $_REQUEST[ "JC_update_" . $key ] as $key_text => $value_text ) ( ! $text ? $text = $value_text : $text .= "\r\n" . $value_text );

					$query .= " `" . $key . "` = " . ( $text ? "'" . $text . "' " : ( $value[ "null" ] ? "NULL" : "''" ) ) . ",";

				}

			}

			$query .= " `log` = CONCAT( `log`, now( ), ' " . $_SESSION[ "JC_account_key" ] . ";\r\n' ), `update` = NOW( )";
			$query .= " WHERE `key` = '" . $_REQUEST[ "JC_update_key" ] . "'";

			JC_query( $query );

			echo "<b>Asynchronous</b> : " . $query . $_REQUEST[ "JC_insert_form" ];

			echo "<script> parent.document.getElementById( 'JC_update_" . $_REQUEST[ "JC_update_key" ] . "' ).innerHTML = ''; </script>";

		}

		function JC_delete( ) {

			$query = "UPDATE `" . $_REQUEST[ "JC_table" ] . "`";
			$query .= " SET `log` = concat( `log`, '\r\n' , now( ), ' " . $_SESSION[ "JC_account_key" ] . "' ), `delete` = NOW( )";
			echo $query .= " WHERE `key` = '" . $_REQUEST[ "JC_delete_key" ] . "'";

			JC_query( $query );

			echo "<b>Asynchronous</b> : " . $query;

			echo "<script> parent.document.getElementById( 'JC_delete_" . $_REQUEST[ "JC_delete_key" ] . "' ).innerHTML = ''; </script>";

		}



	////
	///
	//	Authority

		function JC_authority( $condition ) {

			if( ! $condition || ( $condition && strpos( $condition, $_SESSION[ "JC_account_authority" ] ) !== false ) ) return true;
			else return false;

		}

		function JC_organization( $organization, $account = null ) {

			$query = "SELECT account, `JC_FK_account.name`( `account` ) AS `account FKF` FROM `organization` WHERE `key` = '" . $organization . "'";

			$RS = JC_query( $query );

			if( $RS ) $record = $RS -> fetch_array( ); else return false;

			$result = JC_TA( $record[ "account FKF" ], ":", "\r\n" );

			if( empty( $account ) ) {

				return $result;

			} else {

				return array_key_exists( $account, $result );

			}

		}



	////
	///
	//	Session

		function JC_session( ) {

			$_SESSION[ $_REQUEST[ "JC_key" ] ] = $_REQUEST[ "JC_value" ];

			echo "<b>Asynchronous</b> : \$_SESSION[ '" . $_REQUEST[ "JC_key" ] . "' ] = '" . $_REQUEST[ "JC_value" ] . "';";

		}



	////
	///
	//	File

		function JC_FT( ) { // File Temporary

			global $JC_path;

			$FI = finfo_open( FILEINFO_MIME_TYPE );

			foreach( array_diff( scandir( "JC_80_file_temporary" ), Array( ".", ".." ) ) as $key => $value ) {

				$result[ $value ][ "type" ] = finfo_file( $FI, $JC_path . "/JC_90_file_temporary/" . $value ); // http://vn2.php.net/manual/en/function.finfo-file.php
				$result[ $value ][ "size" ] = filesize( "JC_90_file_temporary/" . $value );

				if( strpos( $result[ $value ][ "type" ], "image" ) !== false ) list( $result[ $value ][ "width" ], $result[ $value ][ "height" ] ) = getimagesize( "JC_90_file_temporary/" . $value );

			}

			finfo_close( $FI );

			return $result;

		}

		function JC_FE( $type ) { // File Extension

			switch( $type ) {

				case "image/jpeg": return "jpg";

				return false;

			}

		}

		function JC_FI( $form ) { // File Insert

			global $JC_path;
			global $JC_host;

			if( empty( $_REQUEST[ "JC_insert_file_" . $form ] ) ) return false;
			if( empty( $_REQUEST[ "JC_insert_host_" . $form ] ) ) return false;

			$FI = finfo_open( FILEINFO_MIME_TYPE );

			$name = JC_MUT( ) . "." . JC_FE( finfo_file( $FI, $JC_path . "/JC_90_file_temporary/" . $_REQUEST[ "JC_insert_file_" . $form ] ) );

			finfo_close( $FI );

			$boolean = true;

			foreach( $_REQUEST[ "JC_insert_host_" . $form ] as $key => $value ) {

				if( $JC_host[ $value ][ "host" ] == "localhost" ) {

					if( ! copy( $JC_path . "/JC_90_file_temporary/" . $_REQUEST[ "JC_insert_file_" . $form ], $JC_path . "/" . $JC_host[ $value ][ "folder" ] . "/" . $name ) ) $boolean = false;

				} else {

					// FTP

				}

			}

			if( $boolean ) unlink( $JC_path . "/JC_90_file_temporary/" . $_REQUEST[ "JC_insert_file_" . $form ] );

			return $name;

		}

		function JC_FU( ) { // File Update

			global $JC_path;
			global $JC_host;

			$RS = JC_query( "SELECT `host`, `name`, `protocol` FROM `file` WHERE `key` = '" . $_REQUEST[ "JC_update_key" ] . "'" );

			if( $RS ) $record = $RS -> fetch_array( );

			$name = $_REQUEST[ "JC_update_name" ] ? $_REQUEST[ "JC_update_name" ] : $record[ "name" ];

			if( $record[ "host" ] && $record[ "protocol" ] == "HTTP" ) {

				$host = JC_TA( $record[ "host" ], null, "\r\n" );

				if( $JC_host[ $host[ 0 ] ][ "host" ] == "localhost" ) {

					if( copy( $JC_path . "/" . $JC_host[ $host[ 0 ] ][ "folder" ] . "/" . $record[ "name" ], $JC_path . "/JC_90_file_temporary/" . $record[ "name" ] ) ) {

						foreach( $host as $key => $value ) if( $JC_host[ $value ][ "host" ] == "localhost" ) unlink( $JC_path . "/" . $JC_host[ $value ][ "folder" ] . "/" . $record[ "name" ] );

					}

				} else {

					// from FTP to localhost

				}

			} else if( $record[ "host" ] && $record[ "protocol" ] == "FTP" ) {

				// FTP

			} else {

				// ...

			}

			$boolean = true;

			foreach( $_REQUEST[ "JC_update_host" ] as $key => $value ) {

				if( $JC_host[ $value ][ "host" ] == "localhost" ) {

					if( ! copy( $JC_path . "/JC_90_file_temporary/" . $record[ "name" ], $JC_path . "/" . $JC_host[ $value ][ "folder" ] . "/" . $name ) ) $boolean = false;

				} else {

					// FTP

				}

			}

			if( $boolean ) unlink( $JC_path . "/JC_90_file_temporary/" . $record[ "name" ] );

			return true;

		}

		function JC_FD( ) { // File Delete

		}



	////
	///
	//	Miscellany

		function JC_MUT( ) { // Micro Unix Timestamp

			$temp = explode( "00 ", microtime( ) );

			return $temp[ 1 ] . substr( $temp [ 0 ], 2 );

		}

		function JC_LR( $URL = false ) { // Location Replace & Reload

			global $JC_MySQL;

			$JC_MySQL -> close( );

			if( $URL )	exit( "<script> try { parent.location.replace( '" . $URL						. "' ); } catch ( exception ) { location.replace( '" . $URL							. "' ); } </script>" );
			else		exit( "<script> try { parent.location.replace( '" . $_SERVER[ "REQUEST_URI" ]	. "' ); } catch ( exception ) { location.replace( '" . $_SERVER[ "REQUEST_URI" ]	. "' ); } </script>" );

			

		}

		function JC_TA( $text, $assign = ":", $separate = ";" ) {  // Text to Array

			if( ! $text ) return null;

			if( strpos( $text, $separate ) == false && strpos( $text, $assign ) == false ) return array( trim( $text ) );

			$sentence = explode( $separate, $text );

			foreach( $sentence as $key => $value ) {

				if( ! $value ) continue;

				if( strpos( $value, $assign ) == false ) {

					$result[ $key ] = trim( $value );

				} else {

					$word = explode( $assign, $value );

					if( $word[ 0 ] ) $result[ trim( $word[ 0 ] ) ] = trim( $word[ 1 ] );

				}

			}

			return $result;

		}

		function JC_TH( $field ) { // Table Header

			$result = null;

			if( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "unit" ] || $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "comment" ] ) {

				$title =	( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "unit"		] ? "The unit of this is '"		. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "unit"		] . "'." : "" );
				$title .=	( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "comment"	] ? ( $title ? "\r\n" : "" )	. $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "comment"	] : "" );

				$result = "<span class=\"help\" title=\"" . $title . "\">" . ucwords( $field ) . "</span>";

			} else {

				$result = ucwords( $field );

			}

			if( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "FKT" ] && JC_authority( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "AIUD" ] ) ) {

				$result .= " <a href=\"?JC_table=" . $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "FKT" ] . "&JC_mode=select\" target=\"JC_FKT\" title=\"Select " . ucwords( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ $field ][ "FKT" ] ) . "\" class=\"normal\">▥</a>";

			}

			return $result;

		}

?>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      